package git.soulbgm.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import git.soulbgm.cache.annotation.Group;
import git.soulbgm.cache.enumeration.TimeLevel;
import git.soulbgm.mapper.DataSegmentSummaryInfoMapper;
import git.soulbgm.pojo.DataSegmentSummaryInfo;
import git.soulbgm.service.DataSegmentSummaryInfoService;
import org.springframework.stereotype.Service;

import java.util.Collection;

import static git.soulbgm.common.Constants.*;

/**
 * 数据段摘要信息服务实现
 *
 * @author SoulBGM
 * @date 2024-09-24
 */
@Service
public class DataSegmentSummaryInfoServiceImpl extends ServiceImpl<DataSegmentSummaryInfoMapper, DataSegmentSummaryInfo> implements DataSegmentSummaryInfoService {

    @Group(groupName = GN_PROCESSING_INFO,
            groupBy = {"sourceCode", "targetCode"},
            aggregation = {"AVG(processingTime != -1)", "AVG(dataSegmentLength)", "MAX(processingTime != -1)", "MIN(processingTime != -1)", "COUNT(sendStatus == 1)", "COUNT(sendStatus == 0)"},
            timeLevel = TimeLevel.MINUTE, dateField = "receiveTime")
    @Override
    public boolean saveBatch(Collection<DataSegmentSummaryInfo> entityList) {
        return super.saveBatch(entityList);
    }
}
